package payroll.classification;


import java.util.LinkedHashMap;
import java.util.Map;

import payroll.PaymentClassification;

public class HourlyClassification implements PaymentClassification {

    private double hourlyRate;
    private Map<String, TimeCard> timeCards = new LinkedHashMap<>();
    public HourlyClassification(double hourlyRate) {
        this.hourlyRate = hourlyRate;
    }

    public double getHourlyRate() {
        return hourlyRate;
    }

    public TimeCard getTimeCardOfDate(String date) {
        return timeCards.get(date);
    }

    public void addTimeCard(TimeCard tc) {
        timeCards.put(tc.getDate(), tc);
    }

    @Override
    public double calculatePay() {
        double total = 0;
        for (TimeCard tc : timeCards.values())
            if(tc.getHours() <= 8)
                total += tc.getHours() * hourlyRate;
            else
                total += 8 * hourlyRate + (tc.getHours() - 8) * hourlyRate * 1.5;
        return total;
    }

}
